package nowcoder.written_examination.wangyi;

import java.util.Scanner;

/**
 * @author fance
 * @date 18-7-1 上午11:04
 */
public class MainIII {
    public static void main(String[] args) {
        b();
//        d();

//    e();

//    f();
//        g();
    }

    public static void g() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int cnt = 0;
            while (n > 0) {
                if (n < 8) {
                    n -= 6;
                    cnt++;
                } else {
                    n -= 8;
                    cnt++;
                }
            }
            if (n != 0) {
                System.out.println(-1);
            } else {
                System.out.println(--cnt);
            }
        }
    }
    public static void f() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            System.out.println(sum(n));
        }
    }
    public static long sum(int n) {
        if (n == 1) {
            return 1;
        }
        if (n % 2 == 0) {
            return sum(n / 2) + n * n / 4;
        } else {
            return sum(n - 1) + n;
        }
    }
    public static void e() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String x = scanner.next();
            String y = scanner.next();
            Integer op1 = Integer.valueOf(rev(x));
            Integer op2 = Integer.valueOf(rev(y));
            String res = String.valueOf(op1 + op2);
            System.out.println(Integer.valueOf(rev(res)));
        }
    }
    public static String rev(String s) {
        return new StringBuilder(s).reverse().toString();
    }
    public static void d() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            long sum = 1;
            for (int i = 0; i < n; i++) {
                sum *= 3;
            }
            if (n < 3) {
                System.out.println(sum);
                continue;
            }
            long remain = 1;
            for (int i = 0; i < n - 3; i++) {
                remain *= 3;
            }
            System.out.println(sum - ((n - 2) * 6 * remain));
        }
    }


   public static void b() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int cnt = 0;
            for (int i = 0; i * i < n; i++) {
                for (int j = 0; j * j < n; j++) {
                    if ((i * i + j * j) == n) {
                        cnt++;
                    }
                }
            }
            cnt *= 4;
            System.out.println(cnt);
        }
    }
        }

